<?php

require '../model-db-connection/config.php';

$project_name = $_GET['project_name'];
$project_code = $_GET['project_code'];
$doc_no = $_GET['doc_no'];
$po_no = $_GET['po_no'];
$home_plan = $_GET['home_plan'];
$home_plot = $_GET['home_plot'];
$po_owner = $_GET['po_owner'];
$po_sender = $_GET['po_sender'];
$issue_date = $_GET['issue_date'];
$order_type = $_GET['order_type'];
$quantity = $_GET['quantity'];
$plan_size = $_GET['plan_size'];
$unit_price = $_GET['unit_price'];
$amount = $_GET['amount'];
$vat7 = $_GET['vat7'];
$supervisor = $_GET['supervisor'];
$project_manager = $_GET['project_manager'];
$projectforeman = $_GET['projectforeman'];
$project_remark = $_GET['project_remark'];
$strAllID = md5(date('m/d/Y h:i:s a', time()));
$sqlInsertIntoMember = "INSERT INTO QRC_PO "
        . "(PO_ID,PO_PROJECT_NAME,PO_PROJECT_CODE,PO_DOCUMENT_NO,PO_PO_NO,PO_HOME_PLAN,PO_HOME_PLOT,PO_OWNER,PO_SENDER,"
        . "PO_ISSUE_DATE,PO_ORDER_TYPE_ID,PO_QUANTITY,PO_PLAN_SIZE,PO_UNIT_PRICE,PO_AMOUNT,PO_VAT,PO_FILE_PATH,"
        . "PO_PROJECT_MANAGER_ID,PO_PROJECT_FOREMAN_ID,PO_SUPERVISOR_ID,PO_REMARK)"
        . " VALUES "
        . "('$strAllID','$project_name','$project_code','$doc_no','$po_no','$home_plan','$home_plot',"
        . "'$po_owner','$po_sender','$issue_date','$order_type','$quantity','$plan_size','$unit_price','$amount',"
        . "'$vat7',NULL,'$project_manager','$projectforeman','$supervisor','$project_remark');";
$resultSet = mysql_query($sqlInsertIntoMember);
$updatePoImg = "UPDATE QRC_PO_IMAGE"
        . " SET TEMP_PO_ID = '$strAllID'"
        . " WHERE TEMP_PO_ID IS NULL;";

mysql_query($updatePoImg);



if ($resultSet) {
    echo '1';
} else {
    echo '0';
}